using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

namespace ZFrameWork.Util
{
    public class ParamsBuilder
    {
        private List<SqlParameter> list = new List<SqlParameter>();

        public void Append(string parameterName, object parameterValue)
        {
            SqlParameter sqlParameter = new SqlParameter(parameterName, parameterValue);
            list.Add(sqlParameter);
        }

        public SqlParameter[] GetParams()
        {
            if (list != null && list.Count > 0)
            {
                int paramsNum = list.Count;
                SqlParameter[] SqlParams = new SqlParameter[paramsNum];

                for (int i = 0; i < list.Count; i++)
                {
                    SqlParams[i] = list[i];
                }

                return SqlParams;
            }

            return null;
        }
    }
}